package com.jfs.qy.strategy;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import com.jfs.qy.entity.response.AlarmList;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description 实时数据上告解析策略
 * @E-mail cwm3412638@163.com
 * @Author cwm
 * @Date 2022/11/4
 */
@Component
@Slf4j
public class RealtimeDataReportProcessStrategy implements AlarmEventProcessStrategy{

    @Override
    public boolean isMatch(List<AlarmList> alarmList) {
        if (CollectionUtil.isNotEmpty(alarmList)) {
            for (AlarmList alarmList1 : alarmList
            ) {
                if (CollectionUtil.isNotEmpty(alarmList1.getRealtimeDataReport())) {
                    return true;
                }
            }
        } else {
            return false;
        }
        return false;
    }

    @Override
    public void doProcessAlarmEvent(List<AlarmList> alarmList) {
        if (log.isDebugEnabled()){
            log.debug("实时数据上告解析策略:{}", JSONUtil.toJsonStr(alarmList));
        }
    }
}
